package utils.base
{
	import flash.geom.Vector3D;
	import flash.utils.ByteArray;
	
	import utils.math.Quaternion;

	public class Joint
	{
		private var _pos:Vector3D;
		private var _orient:Quaternion;
		private var _parentIndex:int;
		public function Joint(parentIndex:int=0,posInput:Vector3D=null,orientInput:Quaternion=null)
		{
			this._parentIndex = parentIndex;
			this._pos = posInput;
			this._orient = orientInput;
			//setOri(orientInput);
		}
		/*private function setOri(v:Vector3D):void{
			var w:Number = 1 - (v.x*v.x+v.y*v.y+v.z*v.z);
			if(w < 0){
				w = 0;
			}else{
				w = -Math.sqrt(w);
			}
			_orient = new Quaternion(v.x,v.y,v.z,w);
		}*/
		public function get pos():Vector3D
		{
			return _pos;
		}

		public function get orient():Quaternion
		{
			return _orient;
		}
		public function clone():Joint{
			
			return null;
		}

		public function get parentIndex():int
		{
			return _parentIndex;
		}
		
		public function writeBytes(byte:ByteArray):void{
			byte.writeInt(_parentIndex);
			byte.writeDouble(_pos.x);
			byte.writeDouble(_pos.y);
			byte.writeDouble(_pos.z);
			byte.writeDouble(_orient.x);
			byte.writeDouble(_orient.y);
			byte.writeDouble(_orient.z);
		}


	}
}